/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controller;

import entity.Room;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import manager.RoomManager;
import manager.StudentManager;

import org.springframework.validation.BindException;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.SimpleFormController;

/**
 *
 * @author daz
 */
public class RoomController extends SimpleFormController {

    private RoomManager roomManager;

    public RoomController() {
        setCommandClass(Room.class);
        setCommandName("roomForm");
    }

    public void setRoomManager(RoomManager roomManager) {
        this.roomManager = roomManager;
    }

    public RoomManager getRoomManager() {
        return roomManager;
    }

    @Override
    protected ModelAndView onSubmit(HttpServletRequest request,
            HttpServletResponse response, Object command, BindException errors)
            throws Exception {
        Room r = (Room) command;
        this.roomManager.insertNewRoom(r);
        return new ModelAndView("RoomSucess", "room", r);

    }
}
